import Vue from "vue";
import VueRouter from "vue-router";

/* Layout */
import Layout from "@/layout";

Vue.use(VueRouter);

export const constantRoutes = [
    {
        path: "/login",
        component: () => import("@/views/login/index"),
        hidden: true
    },
    {
        path: "/404",
        component: () => import("@/views/404"),
        hidden: true
    },

    
    {
        path: "/",
        component: Layout,
        redirect: "/home",
        name: "主页",
        children: [
            {
                path: "home",
                name: "主页",
                component: () => import("@/views/Home"),
                meta: { title: "home" }
            }
        ]
    },
    {
        path: "/issue",
        component: Layout,
        name: "题库管理",
        children: [
            {
                path: "category",
                name: "题库分类",
                component: () => import("@/views/issue/issueCategory")
            }, {
                path: "categoryson",
                name: "题库子分类",
                hidden:true,
                component: () => import("@/views/issue/issueCategorySon")
            },
            {
                path: "list",
                name: "题目列表",
                component: () => import("@/views/issue/issueList"),
            },
            {
                path: "add",
                name: "新增试题",
                hidden:true,
                component: () => import("@/views/issue/addIssue")
            },
            {
                path: "detail",
                name: "题目详情",
                hidden:true,
                component: () => import("@/views/issue/issueDetail")
            },
        ]
    },
    {
        path: "/exam",
        component: Layout,
        name: "考试中心",
        children: [
            {
                path: "index",
                name: "考试列表",
                component: () => import("@/views/exam/index"),
                meta: { title: "exam" },
            },
            {
                path: "message",
                name: "新增考试",
                component: () => import("@/views/exam/message"),
                meta: { title: "selftest" },
            },
            {
                path: "explain",
                name: "考试详情",
                component: () => import("@/views/exam/explain"),
                meta: { title: "exam" },

            },

        ],
    },
    {
        path: "/review",
        component: Layout,
        name: "审核中心",
        children: [

            {
                path: "chcek",
                name: "审核列表",
                component: () => import("@/views/review/check"),
                meta: { title: "check" },
            },

            {
                path: "index",
                name: "审核管理",
                component: () => import("@/views/review/index"),
                meta: { title: "index" },
            },

            {
                path: "list",
                name: "审核详情",
                component: () => import("@/views/review/list"),
                meta: { title: "list" },
            },

        ],
    },
    {
       path: "/test",
        component: Layout,
        name:"考生模块",
        children: [{
           path:"/testPaper",
            hidden: true,
            name:"考生页",
            component:() =>import("@/views/test/testPaper")
        },{
            path:"testList",
            name:"考生考试列表",
            component:() =>import("@/views/test/testList")
        },
        {
            path:"examResults",

            name:"成绩查询",
            component:() =>import("@/views/test/examResults")
        }
        ]

    },
    {
        path: "/paper",
        component: Layout,
        name: "试卷管理",
        children: [
            {
                path: "select",
                name: "多级联动",
                hidden: true,
                component: () => import("@/views/paper/select"),
                meta: { title: "paper" },
            },
            {
                path: "index",
                hidden: true,
                name: "试卷搜索",
                component: () => import("@/views/paper/index"),
                meta: { title: "paper" },
                children: [

                ]
            },
            {
                path: "/detail",
                name: "试卷详情",
                component: () => import("@/views/paper/detail"),
                hidden: true,
                meta: { title: "paper" }

            },
            {
                path: "paperClassManager",
                name: "试卷分类管理",
                component: () => import("@/views/paper/paperClassManager.vue"),
                meta: {title: "paper"}
            },
            {
                path: "add",
                name: "添加试卷",

                component: () => import("@/views/paper/add"),
                meta: { title: "paper" },
                hidden: true,
                children: [
                    {
                        path: "/set",
                        name: "试卷设置",
                        component: () => import("@/views/paper/set"),
                        meta: { title: "paper" }
                    },
                    {
                        path: "/message",
                        name: "试卷基本信息",
                        component: () => import("@/views/paper/message"),
                        meta: { title: "paper" },
                        children: []
                    },
                    {
                        path: "/fixed",
                        name: "添加试卷",
                        component: () => import("@/views/paper/fixed"),
                        meta: { title: "paper" }
                        
                    }
                
                ]
                
            }
        ]
    }
    // { path: "*", redirect: "/404", hidden: true  },
];

const router = new VueRouter({
    mode: "history",
    base: process.env.BASE_URL,
    routes: constantRoutes
});


export default router;

//以上为通用权限路由，下面的为权限路由，只有admin才能访问
export const asyncRoutes = [
    {
        path: "/rootManage",
        component: Layout,
        name: "权限管理",
        alwaysShow: true,
        meta: { title: "rootManage", roles: ["admin"] },
        children: [
            {
                path: "index",
                name: "资料管理",
                component: () => import("@/views/rootManage/index"),
                meta: { title: "rootManage", roles: ["admin"] }
            }
        ]
    }
];
